//
//  SeckillListCell.m
//  phmall
//
//  Created by admin on 2017/10/10.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "SeckillListCell.h"

@implementation SeckillListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    SeckillListCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[SeckillListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.contentView.backgroundColor=[UIColor groupTableViewBackgroundColor];
        self.back=[[UIView alloc]init];
        ViewBorderRadius(self.back, 5, 0, [UIColor clearColor]);
        self.back.backgroundColor=[UIColor whiteColor];
        [self.contentView addSubview:self.back];
        
        self.goodsImage=[[UIImageView alloc]init];
        self.goodsImage.image =[UIImage imageNamed:@"图片"];
        ViewBorderRadius(self.goodsImage, 5, 0, [UIColor whiteColor]);
        [self.contentView addSubview: self.goodsImage];
//
        self.name=[[UILabel alloc]init];
        self.name.text=@"ROSIE FOR AUTOGRAPH 丝绸和蕾丝拼接Beau Plunge胸罩AE";
        self.name.font=[UIFont systemFontOfSize:15];
        self.name.numberOfLines=2;
        [self.contentView addSubview:self.name];
//
        self.message=[[UILabel alloc]init];
        self.message.text=@"前100名 立减40元";
        //        self.specification.numberOfLines=2;
        self.message.font=[UIFont systemFontOfSize:13];
        self.message.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        [self.contentView addSubview:self.message];

        
        self.sellOut=[[UILabel alloc]init];
        self.sellOut.text=@"12小时抢光1000件";
        self.sellOut.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        self.sellOut.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.sellOut];
        
        self.residue=[[ResidueView alloc]init];
        [self.contentView addSubview:self.residue];
        
        self.price=[[UILabel alloc]init];
        self.price.text=@"₱8888.00";
        self.price.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        self.price.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.price];

        self.market_price=[[UILabel alloc]init];
        self.market_price.text=@"₱8888.00";
        self.market_price.textColor=[UIColor colorWithHexString:@"#ff4040"];
        self.market_price.font=[UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.market_price];
        
        self.purchase=[UIButton buttonWithType:UIButtonTypeCustom];
        self.purchase.titleLabel.font=[UIFont systemFontOfSize:10];
        [self.purchase setTitle:@"立即抢" forState:UIControlStateNormal];
        self.purchase.backgroundColor=[UIColor colorWithHexString:@"#FF8200"];
        ViewBorderRadius(self.purchase, 5, 0, [UIColor clearColor]);
        [self.contentView addSubview:self.purchase];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [self.goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.back).offset(10);
        make.bottom.equalTo(self.back).offset(-10);
        make.width.mas_equalTo(self.goodsImage.mas_height);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.goodsImage).offset(0);
        make.left.equalTo(self.goodsImage.mas_right).offset(10);
        make.right.equalTo(self.back).offset(-10);
    }];
    
    [self.message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.name.mas_bottom).offset(5);
        make.left.equalTo(self.name);
    }];
    

    
    [self.market_price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.name);
        make.bottom.equalTo(self.goodsImage.mas_bottom).with.offset(0);
    }];
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.market_price.mas_right).offset(5);
         make.bottom.equalTo(self.goodsImage.mas_bottom).with.offset(0);
    }];
    
    [self.sellOut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.price.mas_top).offset(-5);
        make.left.equalTo(self.name);
    }];
    
    [self.residue mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.name);
        make.centerY.equalTo(self.sellOut);
        make.right.equalTo(self.back).offset(-80);
        make.height.offset(12);
    }];
    
    [self.purchase mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.back).offset(-10);
        make.centerY.equalTo(self.price);
        make.height.offset(20);
        make.width.offset(52);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
